#now is SINGLE check work_info.json : later with MULITI
S1=$1
source ../sys/BlacSetup.sh
source ../sys/.env
cat ../sys/.env
#start=$(date +%s)
MODULE_BASE=${BLACRESBASE}/aero_shape
if ! [ -d ${MODULE_BASE} ]; then
 mkdir ${MODULE_BASE}
fi
MYLOG_BASE=${BLACRESBASE}/aero_shape/logfiles
if ! [ -d ${MYLOG_BASE} ]; then
 mkdir ${MYLOG_BASE}
fi
MYRUNOUTPUT=${BLACRESBASE}/aero_shape/outputs
if ! [ -d ${MYRUNOUTPUT} ]; then
 mkdir ${MYRUNOUTPUT}
fi
SHAPEDIR=${MYRUNOUTPUT}/blade_shape
if ! [ -d ${SHAPEDIR} ]; then
 mkdir ${SHAPEDIR}
fi
MYRUNINPUT=${BLACRESBASE}/aero_shape/inputs
if ! [ -d ${MYRUNOUTPUT} ]; then
 mkdir ${MYRUNOUTPUT}
fi
ITERS='A01 A02 A03 S01 S02 S03 S04  S05 C01 C02 C03 C04 C05 C06 C07'
ITERS_NO='NO'
ITER_FIRST=SINGLE
m=`date|awk '{print $3}'`
d=`date|awk '{print $2}'`
t=`date|awk '{print $4}'`
A1LOG_FILE=${MYLOG_BASE}/sys_run_$m$d-$t.log
echo A1LOG_FILE name ---${A1LOG_FILE}
touch ${A1LOG_FILE}
# deal with

function PREP_INPUT() {
  cp ${BLACRUNBASE}/aero_shape/work_info.json ${MYRUNINPUT}
}

#this is sys module RUN+module_name.sh
 if [ ${A01} = "YES" ]; then
  echo '  ################'
  echo '   Blac Running <<shape generation>> '| tee -a ${A1LOG_FILE}
  echo '   Choice Componets A01=' ${A01}| tee -a ${A1LOG_FILE}
  echo '   Looking at work_info.json for this run to create around 40 shapes'
  echo '  ################'
  rm ${SHAPEDIR}/*.*
  python  ${BLACRUNBASE}/aero_shape/aero_design.py #>>${SYS_LOG}
  #CREATE_ENV
 fi
 if [ ${A02} = "YES" ]; then
  echo '  ################'
  echo '   Blac Running <<shape analysis>> '
  echo '   Choice Components  A01=' ${A01}| tee -a ${A1LOG_FILE}
  echo '  ######## web portal at ########'
  echo ' testing at http://10.57.64.130:8551 '| tee -a ${A1LOG_FILE}
  #nohup streamlit run bem_aep.py --server.port 8550  >/dev/null 2>&1 &
  nohup streamlit run ${BLACRUNBASE}/aero_shape/shape_gen.py --server.port 8551 >>${SYS_LOG} &
  #streamlit run aep.py --server.port 8552
 fi
  echo '   Blac  <<shape analysis>>  is running  now ----'
  sleep 1
  echo '   <<shape analysis>> finished '
  echo '   Please check output shapes at ' ${SHAPEDIR}
#end=$(date +%s)
#runtime=$((end-start))
echo "A1 Shape Generation Execution time: $runtime seconds"
echo $runtime>>${A1LOG_FILE}
sleep 1





